class Tom {
    constructor() {
        this._name = 'Tom';
    }
    get name() {
        return this._name;
    }
    set name(newName) {
        this._name = newName;
    }
}

let tom = new Tom();
tom.name = 'Jerry';
console.log(tom.name); // Jerry